﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using HidesaburoDotNET.Core;
using HidesaburoDotNET.Core.Detecctors;
using HidesaburouDotNetTest.Test.YakuCheck;
namespace HidesaburoDotNET.Test.YakuCheck
{
    [TestFixture]
    public class SagawaCheck
    {
        /// <summary>
        /// イッキツウカンのテスト
        /// </summary>
        [Test]
        public void TestIttsu()
        {

            YakuDetector detector = new IttsuDetector();
            MockAgariTehai agari = null;
            int expectedFan = 0;

            //正常時の判定
            expectedFan = 2;
            //
            agari = new MockAgariTehai(new List<Mentsu>(){
                MockAgariTehai.CreateMentsu(MentsuType.Toitsu,new Hai( HaiType.Pinzu , 2)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Manzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Manzu, 4)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Manzu, 7)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Souzu, 1))
                });
            agari.SelectAgariHai(2, 0);
            agari.Tsumo = true;
            YakuDetectorsTest.AssertCorrectlyChecked(expectedFan, detector, agari);

            expectedFan = 1;
            //
            agari = new MockAgariTehai(new List<Mentsu>(){
                MockAgariTehai.CreateMentsu(MentsuType.Toitsu,new Hai( HaiType.Jihai ,Hai.Chun)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Manzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Manzu, 4)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_M,new Hai( HaiType.Manzu, 7)),
                MockAgariTehai.CreateMentsu(MentsuType.Minkan,new Hai( HaiType.Souzu, 1))
                });
            agari.SelectAgariHai(2, 0);
            agari.Tsumo = false;
            YakuDetectorsTest.AssertCorrectlyChecked(expectedFan, detector, agari);

            //失敗時の判定
            expectedFan = 0;
            //
            agari = new MockAgariTehai(new List<Mentsu>(){
                MockAgariTehai.CreateMentsu(MentsuType.Toitsu,new Hai( HaiType.Pinzu , 2)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Manzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Manzu, 4)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Souzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Souzu, 7))
                });
            agari.SelectAgariHai(2, 0);
            agari.Tsumo = true;
            YakuDetectorsTest.AssertCorrectlyChecked(expectedFan, detector, agari);

            expectedFan = 0;

            agari = new MockAgariTehai(new List<Mentsu>(){
                MockAgariTehai.CreateMentsu(MentsuType.Toitsu,new Hai( HaiType.Manzu , 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Manzu, 2)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Manzu, 4)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_M,new Hai( HaiType.Manzu, 7)),
                MockAgariTehai.CreateMentsu(MentsuType.Anko,new Hai( HaiType.Souzu, 1))
                });
            agari.SelectAgariHai(2, 0);
            agari.Tsumo = true;
            YakuDetectorsTest.AssertCorrectlyChecked(expectedFan, detector, agari);

        }
        /// <summary>
        /// サンショクドウジュンのテスト
        /// </summary>
        [Test]
        public void TestSanshoku()
        {

            YakuDetector detector = new SanshokuDetector();
            MockAgariTehai agari = null;
            int expectedFan = 0;

            //正常時の判定
            expectedFan = 2;
            //
            agari = new MockAgariTehai(new List<Mentsu>(){
                MockAgariTehai.CreateMentsu(MentsuType.Toitsu,new Hai( HaiType.Pinzu , 9)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Manzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Manzu, 4)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Pinzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Souzu, 1))
                });
            agari.SelectAgariHai(2, 0);
            agari.Tsumo = true;
            YakuDetectorsTest.AssertCorrectlyChecked(expectedFan, detector, agari);

            expectedFan = 1;
            //
            agari = new MockAgariTehai(new List<Mentsu>(){
                MockAgariTehai.CreateMentsu(MentsuType.Toitsu,new Hai( HaiType.Jihai , Hai.Hatsu)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Manzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Manzu, 4)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_M,new Hai( HaiType.Pinzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_M,new Hai( HaiType.Souzu, 1))
                });
            agari.SelectAgariHai(2, 0);
            agari.Tsumo = false;
            YakuDetectorsTest.AssertCorrectlyChecked(expectedFan, detector, agari);

            //失敗時の判定
            expectedFan = 0;
            //
            agari = new MockAgariTehai(new List<Mentsu>(){
                MockAgariTehai.CreateMentsu(MentsuType.Toitsu,new Hai( HaiType.Pinzu , 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Manzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Manzu, 4)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Souzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Souzu, 1))
                });
            agari.SelectAgariHai(2, 0);
            agari.Tsumo = true;
            YakuDetectorsTest.AssertCorrectlyChecked(expectedFan, detector, agari);

        }

        /// <summary>
        /// サンショクドウコーのテスト
        /// </summary>
        [Test]
        public void TestSandoko()
        {

            YakuDetector detector = new SandokoDetector();
            MockAgariTehai agari = null;
            int expectedFan = 0;

            //正常時の判定
            expectedFan = 2;
            //
            agari = new MockAgariTehai(new List<Mentsu>(){
                MockAgariTehai.CreateMentsu(MentsuType.Toitsu,new Hai( HaiType.Jihai , Hai.Pe)),
                MockAgariTehai.CreateMentsu(MentsuType.Anko,new Hai( HaiType.Manzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Anko,new Hai( HaiType.Pinzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Anko,new Hai( HaiType.Souzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Souzu, 5))
                });
            agari.SelectAgariHai(2, 0);
            agari.Tsumo = true;
            YakuDetectorsTest.AssertCorrectlyChecked(expectedFan, detector, agari);

            expectedFan = 2;
            //
            agari = new MockAgariTehai(new List<Mentsu>(){
                MockAgariTehai.CreateMentsu(MentsuType.Toitsu,new Hai( HaiType.Manzu , 5)),
                MockAgariTehai.CreateMentsu(MentsuType.Anko,new Hai( HaiType.Manzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Anko,new Hai( HaiType.Pinzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Minko,new Hai( HaiType.Souzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Minko,new Hai( HaiType.Jihai, Hai.Ton))
                });
            agari.SelectAgariHai(2, 0);
            agari.Tsumo = false;
            YakuDetectorsTest.AssertCorrectlyChecked(expectedFan, detector, agari);

            //失敗時の判定
            expectedFan = 0;
            //
            agari = new MockAgariTehai(new List<Mentsu>(){
                MockAgariTehai.CreateMentsu(MentsuType.Toitsu,new Hai( HaiType.Jihai , Hai.Pe)),
                MockAgariTehai.CreateMentsu(MentsuType.Anko,new Hai( HaiType.Manzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Pinzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Anko,new Hai( HaiType.Souzu, 1)),
                MockAgariTehai.CreateMentsu(MentsuType.Syuntsu_A,new Hai( HaiType.Souzu, 5))
                });
            agari.SelectAgariHai(2, 0);
            agari.Tsumo = true;
            YakuDetectorsTest.AssertCorrectlyChecked(expectedFan, detector, agari);

        }
    }
}
